package com.example.demo01;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

/**
 * description: HashMapDemo <br>
 * date: 2021/2/5 15:01 <br>
 *
 * @author: ZhangYixin <br>
 * version: 1.0 <br>
 */
public class HashMapDemo {
    public static void main(String[] args) {
        HashMap<String,String> hashMap = new HashMap<>();
        hashMap.put("","");
        hashMap.put(null,"");
        hashMap.put("s1",null);
        System.out.println(hashMap.get("")+"空值");
        System.out.println(hashMap.get(null)+"null值");
        System.out.println(hashMap.get("s1"));
        new Thread(()->{
            System.out.println(Thread.currentThread().getName());
        }).start();

        String str1 = new String("柳柴");
        String str2 = new String("柴柕");
        System.out.println(str1.hashCode()==str2.hashCode());
        HashMap<String,String> hashMap1 = new HashMap<>();
        hashMap1.put("柳柴","s1");
        hashMap1.put("柴柕","s2");
        System.out.println(hashMap1.get("柳柴"));
        System.out.println(hashMap1.get("柴柕"));

        TreeMap<Integer,String> treeMap = new TreeMap<>();
        treeMap.put(2,"sp2");
        treeMap.put(1,"sp1");
        treeMap.put(4,"sp4");
        treeMap.put(3,"sp3");

        Iterator<Map.Entry<Integer, String>> iterator = treeMap.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<Integer, String> next = iterator.next();
            Integer key = next.getKey();
            String value = next.getValue();
            System.out.println("key:"+key+"vlaue:"+value);
        }
    }
}
